package com.freejy.ecommunity.service;

import com.freejy.ecommunity.mapper.Topic1Mapper;
import com.freejy.ecommunity.model.Topic1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jerry
 */
@Service
public class Topic1Service
{

    @Autowired
    private Topic1Mapper topicMapper;


    /**
     * 保存帖子信息
     * @param model
     * @return
     */
    public boolean save(Topic1 model)
    {
        boolean res = false;
        if (model != null) {
            int cnt = topicMapper.insertSelective(model);
            res = cnt>0?true:false;
        }
        return res;
    }

    /**
     * 修改帖子信息
     * @param model
     * @return
     */
    public boolean update(Topic1 model)
    {
        boolean res = false;
        topicMapper.updateByPrimaryKeySelective(model);
        return res;
    }

    /**
     * 根据ID查询帖子信息
     * @param id
     * @return
     */
    public Topic1 findById(Long id)
    {
        Topic1 model = null;
        if (id != null) {
            model = topicMapper.findById(id);
        }
        return model;
    }

    /**
     * 查询用户的帖子列表
     * @param uid
     * @param pageSize
     * @param start
     * @return
     */
    public List<Topic1> findByUid(Long uid, Integer pageSize, Long start)
    {
        List<Topic1> list = new ArrayList<>();
        return list;
    }

    /**
     * 查询所有帖子
     * @param pageSize
     * @param start
     * @return
     */
    public List<Topic1> findList(Integer pageSize, Long start)
    {
        List<Topic1> list = new ArrayList<>();
        return list;
    }

    /**
     * 查询热门帖子
     * @param pageSize
     * @param start
     * @return
     */
    public List<Topic1> findHot(Integer pageSize, Long start)
    {
        List<Topic1> list = new ArrayList<>();
        return list;
    }

    /**
     * 删除帖子
     * @param id
     * @return
     */
    public boolean delete (Long id)
    {
        boolean res = false;
        return res;
    }


}
